<?php
require_once('settings.php');
require_once('header.php');
require_once('lib/misc_functions.php');
require_once('lib/mysql.php');

//connect to the db
$conn = mysql_up(false);

$sqlquery = "
UPDATE
    players,
    (SELECT f_player_id AS 'pid', FLOOR(1/2*COUNT(*)) AS 'dspp' FROM match_data, matches WHERE f_match_id = match_id AND match_id > 0 AND date_played IS NOT NULL GROUP BY f_player_id) AS tmpTable
SET
    extra_spp = dspp
WHERE
    pid = player_id"
;
mysql_query($sqlquery);
echo "Updating SPP";
mysql_close($conn);
?>